//测试通用api db.js

const db = require("./db.js")

//插入操作
let sql_insert = "insert into book set ?"
let data_insert = {
    name: "小李飞刀",
    author: "古龙",
    category: "武侠",
    description: "武侠小说"
}

db.base(sql_insert, data_insert, (result) => {
    console.log(result)
})

//更新操作
let sql_update = "update book set name=?, author=?, category=?, description=? where id=?"
let data_update = ['天涯明月刀', '古龙', '武侠', '一个武侠的世界', 20]

db.base(sql_update, data_update, (result) => {
    console.log(result)
})

//删除操作
let sql_delete = "delete from book where id=?"
let data_delete = [22]
db.base(sql_delete, data_delete, (result) => {
    console.log(result)
})

//查询操作
let sql_select = "select * from book where id>?"
let data_select = [11]
db.base(sql_select, data_select, (result) => {
    console.log(result)
})